# -*- coding: utf-8 -*-
# @Time    : 2023/6/3 17:00
# @Author  : 刘张宇
# @Email   : 2285524065@qq.com
# @File    : .py
# @Software: PyCharm
from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage

class BrowsingHistory(BasePage):
    view_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/recycler_view"]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.FrameLayout[1]')#查看视频（添加浏览记录）
    quit_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/iv_back"]')#退出视频


    browsing_history_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/dt_visit_history"]')#点击浏览历史定位器
    edit_locator = (By.XPATH, '//*[@content-desc="编辑"]')#点击编辑定位器
    check_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/iv_check_box"]')#勾选定位器
    delete_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/tv_delete"]')#删除定位器
    Confirm_the_delete_locator = (By.XPATH, '//*[@resource-id="com.xiachufang:id/tv_right"]')#确定删除定位器
    title_locator = (By.XPATH, '//*[@text="宫保鸡丁这么做简单易学好吃下饭"]')

    def menu_view(self):
        self.find_element(self.view_locator).click()#（创建浏览记录）查看商品

    def menu_quit(self):
        self.find_element(self.quit_locator).click()#（创建浏览记录）退出商品

    def menu_browsing_history(self):
        self.find_element(self.browsing_history_locator).click()#点击浏览历史

    def menu_edit(self):
        self.find_element(self.edit_locator).click()#点击编辑

    def menu_check(self):
        self.find_element(self.check_locator).click()#勾选

    def menu_delete(self):
        self.find_element(self.delete_locator).click()#删除

    def menu_Confirm_the_delete(self):
        self.find_element(self.Confirm_the_delete_locator).click()#确定删除

    def task_first(self):
        current_task = self.find_element(self.title_locator).text
        return current_task